home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / CFDFront / TOptFlow.cp < prev    next >
Encoding:
Text File  |  1992-02-21  |  4.6 KB  |  138 lines  |  [TEXT/MPS ]

  1. #pragma segment MenuOption
  2. //*********************************************************************************
  3. //    TOptFlow - Methods
  4. //        inherits all methods and vars from TDialogView
  5. //        overrides method : DoChoice
  6. //*********************************************************************************
  7. //------------------------------------------------------------------------------------------
  8. //    TOptFlow DoChoice Method... Implementation
  9. //------------------------------------------------------------------------------------------
  10. pascal void TOptFlow::DoChoice(TView *origView, short itsChoice)
  11.     {
  12.     TWindow    * aWindow;
  13.     TRadio        * aRadio;
  14.     short        index;
  15.     long             temp, t, t1;
  16.     
  17.     aWindow = this->GetWindow();                                                // get the window
  18.     temp = ((TCFDFrontDocument *) fDocument)->GetFlowOpts();
  19.     if (itsChoice == mRadioHit)                                                    // a radio button was selected
  20.         {
  21.         for (index = 1; index < 15; index++)                                    // look at all buttons
  22.             {
  23.             this->GetControlName(index,"RD");                                // get button name
  24.             t     = pow(2,(index-1));                                                    // get bit value
  25.             t1    = temp & t;                                                                // is it on?
  26.             
  27.             aRadio = (TRadio *) aWindow->FindSubView(tbox.boxID);
  28.             if (origView == aRadio)                                                 // get radio button
  29.                 {
  30.                 if (((TRadio *) origView)->IsOn())                                // is this button on?
  31.                     this->DoLayerDialog((TRadio *) origView,index);    // display additional dialog
  32.                 }
  33.             if (t1 == t && !aRadio->IsOn())                                        // was it on before
  34.                 temp -= t;                                                                // no : turn on
  35.             else if (t1 == 0 && aRadio->IsOn())
  36.                 temp += t;                                                                // yes : turn off
  37.             }
  38.         ((TCFDFrontDocument *) fDocument)->SetFlowOpts(temp);    // store radio configuration
  39.         }
  40.     
  41.     inherited::DoChoice(origView,itsChoice);
  42.     }
  43.     
  44. //------------------------------------------------------------------------------------------
  45. //    Dismiss the Dialog
  46. //------------------------------------------------------------------------------------------
  47. pascal void TOptFlow::DismissDialog(ResType dismisser)
  48.     {
  49.     ((TCFDFrontDocument *) fDocument)->SetDialogOn(false,cFlowDialog);
  50.     inherited::DismissDialog(dismisser);
  51.     }
  52.  
  53. //------------------------------------------------------------------------------------------
  54. //    TOptFlow DoLayerDialog
  55. //------------------------------------------------------------------------------------------
  56. void TOptFlow::DoLayerDialog(TRadio * /*theButton*/, short index)
  57.     {
  58.     TWindow * dWindow;                                                                    // the window
  59.     
  60.     switch (index)
  61.         {
  62.         case 2 :
  63.             TPressure * thePressure;
  64.             
  65.             dWindow = NewTemplateWindow(kOptPressure,fDocument);    // create the dialog box
  66.             if (dWindow == NULL)
  67.                 return;
  68.             thePressure = (TPressure *) (dWindow->FindSubView('pres')); // get radius class
  69.             thePressure->GetParams();
  70.             break;
  71.         
  72.         case 3 :
  73.             TPremix * theMix;
  74.             
  75.             dWindow = NewTemplateWindow(kOptPremix,fDocument);        // create the dialog box
  76.             if (dWindow == NULL)
  77.                 return;
  78.             theMix = (TPremix *) (dWindow->FindSubView('prem'));         // get radius class
  79.             theMix->GetParams();
  80.             break;
  81.         
  82.         case 4 :
  83.             TDiffusion * theDiffusion;
  84.             
  85.             dWindow = NewTemplateWindow(kOptDiffusion,fDocument);        // create the dialog box
  86.             if (dWindow == NULL)
  87.                 return;
  88.             theDiffusion = (TDiffusion *) (dWindow->FindSubView('diff'));     // get radius class
  89.             theDiffusion->GetParams();
  90.             break;
  91.         
  92.         case 6 :
  93.             TTurbulence * theTurbulence;
  94.             
  95.             dWindow = NewTemplateWindow(kOptTurbulence,fDocument);    // create the dialog box
  96.             if (dWindow == NULL)
  97.                 return;
  98.             theTurbulence = (TTurbulence *) (dWindow->FindSubView('turb')); // get radius class
  99.             theTurbulence->GetParams();
  100.             break;
  101.         
  102.         case 8 :
  103.             TBoundryRadius * theRadius;
  104.             
  105.             dWindow = NewTemplateWindow(kOptRadius,fDocument);        // create the dialog box
  106.             if (dWindow == NULL)
  107.                 return;
  108.             theRadius = (TBoundryRadius *) (dWindow->FindSubView('RADI')); // get radius class
  109.             theRadius->GetParams();
  110.             break;
  111.         
  112.         }
  113.     return;
  114.     }
  115.             
  116. //------------------------------------------------------------------------------------------
  117. //    Mark the options correctly
  118. //------------------------------------------------------------------------------------------
  119. void TOptFlow::MarkRadioButton (Boolean * radioButton)
  120.     {
  121.     TWindow     * aWindow;
  122.     TRadio         * button;
  123.     short index;
  124.     
  125.     aWindow = this->GetWindow();                                                    // get reference to the window
  126.  
  127.     for (index = 1; index <= 14; index++)                                        // do all check boxes
  128.         {
  129.         this->GetControlName(index,"RD");                                        // puts checkbox name in tbox    
  130.         button = (TRadio *) aWindow->FindSubView(tbox.boxID);        // get pointer to the box
  131.             
  132.         if (radioButton[index-1])                                                        // is this box on?
  133.             button->SetState(true,false);                                            // yes mark it
  134.         else
  135.             button->SetState(false,false);
  136.         }
  137.     }
  138.